#pragma once

#include "corebase_global.h"
#include <osg/Vec3>
#include <osg/Vec2>
#include <osgUtil/LineSegmentIntersector>
#include <QVector>
#include <osgViewer/Viewer>

namespace osg
{
	class Camera;
}

namespace CoreBase
{
	//class Camera;
	class Scene;
	class Drawable;
	//class KeyboardMouseHandler;
	//class Keyboard;
	//class Mouse;
	//class DatabasePager;
	class ViewImpl;

	class COREBASE_EXPORT Viewer : public osgViewer::Viewer
	{
	public:
		Viewer(bool usescenelight = true);
		void setRenderOrder(unsigned int rordernum);
		unsigned int getRenderOrder() const;
		void setMainCamera(osg::Camera* camera);
		void setScene(Scene* scene);
		Scene* getScene();
		const Scene* getScene() const;
		osgViewer::Viewer* getOsgViewerView();
		const osgViewer::Viewer* getOsgViewerView() const;
		bool isSetupScene(){return _setupScene;}
		//Keyboard* GetKeyboard();
		//const Keyboard* GetKeyboard() const;
		//void SetMouse(Mouse* mouse);
		//Mouse* GetMouse();
		//const Mouse* GetMouse() const;
		//void SetDatabasePager(dtCore::DatabasePager* pager);
		//dtCore::DatabasePager* GetDatabasePager();
		//const dtCore::DatabasePager* GetDatabasePager() const;
		//bool addSlave(osg::Camera* camera);
		//bool removeSlave(osg::Camera* camera);
		//void clearSlave();
	protected:
		virtual ~Viewer();
		friend class Scene;
		void updateFromScene();
		//typedef QVector<osg::ref_ptr<osg::Camera>>			CameraSet;
		//CameraSet											_cameraSlave;
		osg::ref_ptr<Scene>									_scene;
		bool												_setupScene;
		//osg::ref_ptr<dtCore::KeyboardMouseHandler> mKeyboardMouseHandler;
		double												_targetFrameRate;
		unsigned int										_renderOrder;
		//osg::ref_ptr<DatabasePager> mPager;
	private:
		void ctor(bool usescenelight);
		//KeyboardMouseHandler* CreateKeyboardMouseHandler();
		//ViewImpl* mImpl;
	};
}